/*
 * @Author: 哈兰德
 * @Description: 配置活动记录操作轨迹
 */
import Vue from 'vue'

const state =() => ({
  steps: [],
  stepsl: 0,
  tag: true// 是否能更新
}) 

const getters = {
  steps: state => state.steps,
  stepsl: state => state.stepsl
}

const mutations = {
  stepsAdd1 (state, step, lockTag) {

    if (!state.tag) {
      return
    }

    if (lockTag) {
      state.tag = false
    }
    // 开头插入
    let text = JSON.parse(JSON.stringify(step))
    state.steps.unshift(text)
    state.stepsl++
    // 历史记录,保存50步     
    if (state.steps.length > 50) {
      state.steps.pop() // 删除最后一个元素
    }
  },
  stepsRemove1 (state) {
    state.steps.shift()
    state.stepsl--
  },
  stepsEmpty (state) {
    state.steps = []
  },
  stepLock (state, value) {
    state.tag = value
  }
}

const actions = {

}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
